<!DOCTYPE html>
<html>

<head>

    {include file="Public/header"}
      <link rel="stylesheet" href="__STATIC__/layout/css/demo.css" type="text/css">
    <link href="__STATIC__/layout/css/gyq.css" rel="stylesheet">
    <style>
     
        table tr td {
            color: #333
        }

        ;
        div table tr td a.table_A {
            display: inline-block;
            padding: 4px 6px;
            border: 1px solid #ccc;
            border-radius: 6px;
            text-align: center;
            color: #333
        }
    </style>

</head>

<body class="white-bg" style="padding: 0;margin:0">
 <div class="page-heade">
       <h2 class="title_color text-center">修改经销商基本信息</h2>
</div>
<form action="" class="form-inline"  method="post" id="add">
    <table class="table table-bordered">
        <tr>
            <td style="width: 140px"><label for="">销售分区<span class="colorRed">*</span>：</label></td>
            <td>
              <select name="zoning" id="fenqu" class="form-control select">
                <option value="">请选择</option>
                {volist name="fenqu" id="row"}
                <option value="{$row.id}" {if $data.zoning==$row.id}selected{/if}>{$row.title}</option>
                {/volist}
             </select>
            </td>
        </tr>
        <tr>
            <td><label for="">销售省份<span class="colorRed">*</span>：</label></td>
            <td>
              <select name="provice" id="provice" class="form-control select">
                <option value="">请选择</option>
                {volist name="provice" id="row"}
                <option value="{$row.id}" {if $data.provice==$row.id}selected{/if}>{$row.title}</option>
                {/volist}
             </select>
            </td>
        </tr>
        <tr>
            <td> <label for="">销售城市<span class="colorRed">*</span>：</label></td>
            <td>
             <select name="city" id="city" class="form-control select">
                <option value="">请选择</option>
                {volist name="city" id="row"}
                <option value="{$row.id}" {if $data.city==$row.id}selected{/if}>{$row.title}</option>
                {/volist}
             </select>
            </td>
        </tr>
        <tr>
            <td><label for="">详细地址<span>*</span>：</label></td>
            <td><input type="text" name="addr" value="{$data.addr}" class="form-control"></td>
        </tr>
        <tr>
            <td><label for="">经销商编号<span class="colorRed">*</span>：</label></td>
            <td>
                <input type="text" name="sn" value="{$data.sn}" class="form-control" disabled>
                <span style="color: red">(经销商编号不能重复)</span>
            </td>
        </tr>
        <tr>
            <td><label for="">经销商名称<span class="colorRed">*</span>：</label></td>
            <td>
                <input type="text" name="title" value="{$data.title}" class="form-control" size="70">
                <span style="color: red">不允许英文状态下输入的单引号!</span>
                <span>(经销商名称不能重复)</span>
            </td>
        </tr>
        <tr>
            <td><label for="">是否为直营：</label></td>
            <td> <span>
               <input type="radio" name="direct" id="optionsRadios1" value="0" {if $data.direct==0}checked{/if}>是
               <input type="radio" name="direct" id="optionsRadios2" value="1"  {if $data.direct==1}checked{/if}>否
            </span></td>
        </tr>
        <tr>
            <td> <label for="">发票类型：</label></td>
            <td>
              <span>
                <input type="radio" name="invoicetype" id="optionsRadios3" value="0"  {if $data.invoicetype==0}checked{/if}>增值税发票
                <input type="radio" name="invoicetype" id="optionsRadios4" value="1"  {if $data.invoicetype==1}checked{/if}>普通发票
              </span>
            </td>
        </tr>
        <tr>
            <td><label for="types">经销商等级<span class="colorRed">*</span>：</label></td>
            <td>
                <select name="types" id="types" class="form-control select">
                    <option value="">请选择</option>
                    <option value="1" {if $data.types==1}selected{/if}>其他</option>
                    <option value="2" {if $data.types==2}selected{/if}>核心经销商</option>
                    <option value="3" {if $data.types==3}selected{/if}>二级经销商</option>
                    <option value="4" {if $data.types==4}selected{/if}>一级经销商</option>
                </select>
            </td>
        </tr>
        <tr>
            <td> <label for="channeltype">经销商渠道类型<span class="colorRed">*</span>：</label></td>
            <td>
              <select name="channeltype" id="channeltype" class="form-control select">
                <option value="">请选择</option>
                {volist name="cg_channel_types1" id="row"}
                <option value="{$row.id}" {if $row.id==$data.channeltype}selected{/if}>{$row.title}</option>
                {/volist}
              </select>
            </td>
        </tr>
        <tr>
            <td><label for="">开始合作时间<span class="colorRed">*</span>：</label></td>
            <td>
                 <input type="text" name="cooptime" value="{:date('Y-m-d',$data.cooptime)}" id="hello" class=" form-control layer-date"
                   style="width: 150px;height: 22px">
            </td>
        </tr>
        <tr>
            <td><label for="">经销商目标费用率<span class="colorRed">*</span>：</label></td>
            <td><input type="number" name="costrate" value="{$data.costrate}" class="form-control select">%</td>
        </tr>
        <tr>
            <td colspan="2" class="text-center">
                <button type="button" class="btn btn-primary" id="tijiao">提交</button>
            </td>
        </tr>
    </table>
</form>

<!-- 全局js -->
{include file="Public/footer"}
<script src="__STATIC__/layout/js/plugins/layer/layer.min.js"></script>
<!-- 自定义js -->

<!-- 第三方插件 -->
<script src="__STATIC__/layout/js/plugins/pace/pace.min.js"></script>
<script src="__STATIC__/layout/js/plugins/layer/laydate/laydate.js"></script>
<script>
    $(function () {
        $('#fenqu').on('change',function () {
            if($(this).val()){
                $('#provice').load('{:url("zcity/getprovices")}?id='+$(this).val())
                $('#city').html('<option value="">请选择</option>')
            }else
                $('#provice').html('<option value="">请选择</option>')
        })
        $('#provice').on('change',function () {
            if($(this).val())
                $('#city').load('{:url("jxsgl/getcities")}?id='+$(this).val())
            else
                $('#city').html('<option value="">请选择</option>')
        })

        //提交
        $('#tijiao').on('click',function () {
            var form =  $('#add')
            var serial = form.serialize()

            console.log(serial)
            $.ajax({
                'type':'post',
                'url':form.attr('action'),
                'data':serial,
                'dataType':'json',
                'success':function (data) {
                    if(data.success){
                        swal({
                            title: data.msg,
                            type: "success"
                        },function(){
                            parent.layer.close(parent.layer.getFrameIndex(window.name))
                        });

                    }else
                        swal({
                            title: data.msg,
                            type: "warning"
                        });
                }
            })
            return false
        })
    })

</script>
<script>
    //外部js调用
    laydate({
        elem: '#hello', //目标元素。由于laydate.js封装了一个轻量级的选择器引擎，因此elem还允许你传入class、tag但必须按照这种方式 '#id .class'
        event: 'focus' //响应事件。如果没有传入event，则按照默认的click
    });

    //日期范围限制
    var start = {
        elem: '#start',
        format: 'YYYY/MM/DD hh:mm:ss',
        min: laydate.now(), //设定最小日期为当前日期
        max: '2099-06-16 23:59:59', //最大日期
        istime: true,
        istoday: false,
        choose: function (datas) {
            end.min = datas; //开始日选好后，重置结束日的最小日期
            end.start = datas //将结束日的初始值设定为开始日
        }
    };
    var end = {
        elem: '#end',
        format: 'YYYY/MM/DD hh:mm:ss',
        min: laydate.now(),
        max: '2099-06-16 23:59:59',
        istime: true,
        istoday: false,
        choose: function (datas) {
            start.max = datas; //结束日选好后，重置开始日的最大日期
        }
    };
    laydate(start);
    laydate(end);
</script>
</body>

</html>